module.exports = app => {
    const express = require("express")
    const router = express.Router({
        mergeParams: true //合并url参数不然app.use的参数在后续代码中无法获取
    })

    //接口书写

    //category通用接口
    // app.use('/web/api/category/:resource', async(req, res, next) => {
    //     //中间件
    //     //将从url获取的:resource用inflection转换成大写单词
    //     const modelName = require('inflection').classify(req.params.resource);
    //     req.Model = require(`../../models/${modelName}`); //req.model挂载这个model
    //     next();
    // }, router)

    //上传图片
    const saveFiles = require("../../controller/savefile/savefile")
    const requireVisual = require("../../controller/visual/index")
    app.post("/web/api/yunyiUpload/put-file",
        requireVisual.buildExists,
        saveFiles.savefile().single('file'),
        requireVisual.postPutFile)

    //登录
    const requirLogin = require("../../controller/login/index")
    app.post('/web/api/login/postlogin',
        requirLogin.postLogin)

    app.post('/web/api/login/postRegister',
        requirLogin.postRegister)

    //用户管理
    const requireyunyiUser = require("../../controller/yunyi/user")
    app.get('/web/api/yunyiUser/list',
        requireyunyiUser.getUserList
    )
    app.post('/web/api/yunyiUser/updata',
        requireyunyiUser.postUpdateUser
    )
    app.get('/web/api/yunyiUser/remove',
        requireyunyiUser.postRemoveUser
    )

    //文章管理
    const requireyunyiArt = require("../../controller/yunyi/userCloud")
    app.get('/web/api/yunyiUser/artlist',
        requireyunyiArt.getArtList
    )
    app.post('/web/api/yunyiUser/newart',
        requireyunyiArt.postNewArt
    )
    app.post('/web/api/yunyiUser/publish',
        requireyunyiArt.postPublish
    )
    app.post('/web/api/yunyiUser/updataart',
        requireyunyiArt.postUpdateArt
    )
    app.get('/web/api/yunyiUser/removeart',
        requireyunyiArt.postRemoveArt
    )

    //上传审核 社区文章管理
    const requireyunyiCommunity = require("../../controller/yunyi/community")
    app.get('/web/api/yunyiUser/checklist',
        requireyunyiCommunity.getCheckList
    )

    app.get('/web/api/yunyiUser/removecheck',
        requireyunyiCommunity.postRemoveCheck
    )

    app.post('/web/api/yunyiUser/newcommunity',
        requireyunyiCommunity.postNewCommunity
    )

    app.get('/web/api/yunyiUser/communityList',
        requireyunyiCommunity.getCommunityList
    )

    app.post('/web/api/yunyiUser/removecommunity',
        requireyunyiCommunity.postRemoveCommunity
    )

    app.post('/web/api/yunyiUser/updatecommunity',
        requireyunyiCommunity.postUpdateCommunity
    )

    //好友分享文章管理

    //评论管理



    //category/list
    // const requirCategory = require("../../controller/category/index");
    // app.get('/web/api/category/list',
    //     requirCategory.getList
    // )
    // app.get('/web/api/category/detail',
    //     requirCategory.getDetail
    // )
    // app.post('/web/api/category/save',
    //     requirCategory.postSave
    // )
    // app.post('/web/api/category/update',
    //     requirCategory.postUpdate
    // )
    // app.post('/web/api/category/remove',
    //     requirCategory.postRemove
    // )

    //   map/getList
    // const requireMap = require("../../controller/map/index")
    // app.get('/web/api/map/list',
    //     requireMap.getList
    // )

    // app.get('/web/api/map/detail',
    //     requireMap.getDetail
    // )

    // app.post('/web/api/map/save',
    //     requireMap.postSave
    // )

    // app.post('/web/api/map/update',
    //     requireMap.postUpdate
    // )

    // app.post('/web/api/map/remove',
    //     requireMap.postRemove
    // )

    // app.get('/web/api/map/data',
    //     requireMap.getData)

    // visual
    // const requireVisual = require("../../controller/visual/index")
    // app.get('/web/api/visual/list',
    //     requireVisual.getList)

    // app.get('/web/api/visual/detail',
    //     requireVisual.getDetail)

    // app.post("/web/api/visual/save",
    //     requireVisual.postSave)

    // app.post("/web/api/visual/update",
    //     requireVisual.postUpdate)

    // app.post("/web/api/visual/remove",
    //     requireVisual.postRemove)

    // app.post("/web/api/visual/copy",
    //     requireVisual.postCopy)

    // const saveFiles = require("../../controller/savefile/savefile")
    // app.post("/web/api/visual/put-file",
    //     requireVisual.buildExists,
    //     saveFiles.savefile().single('file'),
    //     requireVisual.postPutFile)

    // app.post("/web/api/visual/put-file-ImgBg",
    //     saveFiles.getBgNum,
    //     saveFiles.saveBackground().single('file'),
    //     requireVisual.postPutFileImg)

    // app.post("/web/api/visual/put-file-Image",
    //     saveFiles.getBgNum,
    //     saveFiles.saveImage().single('file'),
    //     requireVisual.postPutFileImg
    // )

    // app.post("/web/api/visual/put-file-Border",
    //     saveFiles.getBgNum,
    //     saveFiles.saveBorder().single('file'),
    //     requireVisual.postPutFileImg
    // )
}